package com.sqm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqm.entity.Comment;
import com.sqm.mapper.CommentMapper;
import com.sqm.service.CommentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能:
 * 作者: 沙琪马
 * 日期: 2024/11/27 19:02
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Resource
    private CommentMapper commentMapper;

    @Override
    public List<Comment> listByPostId(String postId) {
        return this.lambdaQuery().eq(Comment::getPostId, postId).list();
    }

    @Override
    public List<Comment> getCommentsByPostId(String postId) {
        return commentMapper.selectList(new QueryWrapper<Comment>().eq("post_id", postId));
    }
}